﻿using System.Security.Principal;
using JSC.Portal.Entities;

namespace JSC.Portal.Security
{
    public class PortalPrincipal : IPrincipal
    {
        private PortalUser _portalUser;

        public PortalPrincipal(PortalUser user)
        {
            _portalUser = user;
        }

        #region IPrincipal Members

        public IIdentity Identity
        {
            get { return _portalUser; }
        }

        public bool IsInRole(string roleString)
        {
            foreach (Role role in _portalUser.Roles)
            {
                if (role.Name.Equals(roleString))
                    return true;
            }
            return false;
        }

        #endregion
    }
}
